
#include "dynamic.h"

using namespace WtfEngine;


void IDynamic::Init() {
	ObjectUpdater::GetInstance().PushObject(this);
};

void IDynamic::Destroy() {
	ObjectUpdater::GetInstance().RemoveObject(this);
};

void ObjectUpdater::Run() {
	// Process the remove list
	for(tRemoveList::iterator i = RemoveList.begin(); i != RemoveList.end(); i++) {
		UpdateList.erase(*i);
	};
	RemoveList.clear();

	// Now process the update list
	for(tUpdateList::iterator i = this->UpdateList.begin(); i != this->UpdateList.end(); i++) {
		if(RemoveList.find(*i) == RemoveList.end()) {
			(*i)->Update();
		};
	};
};

